import { request } from '@/utils/request'
import uploadFile from '@/utils/request/uploadFile.js'
const user = {
	// 登录
	login({username, password, code, uuid}) {
		const data = {
		    username,
		    password,
		    code,
		  }
		let params = {
			url: `login`,
			headers: {
			  'Content-Type': 'application/json'
			},
			method: 'post',
			data: data
		}
		return request(params)
	},
	// 注销
	logout() {
		let params = {
			url: `logout`,
			method: 'post'
		}
		return request(params)
	},
	// 修改密码
	changePassword(oldPassword, newPassword) {
		const data = {
		  oldPassword,
		  newPassword
		}
		let params = {
			method: 'put',
			url: `system/user/profile/updatePwd?oldPassword=${oldPassword}&newPassword=${newPassword}`,
			// data: data
		}
		return request(params)
	},
	// 获取用户信息
	getInfo(id) {
		let params = {
			method: 'GET',
			url: `system/user/getInfoApp`,
		}
		return request(params)
	},
	// 修改用户信息
	updateInfo(data) {
		let params = {
			method: 'put',
			url: `system/user/upDateUserInfo`,
			data: data
		}
		return request(params)
	},
	// 用户头像修改
	updateavator(data) {
		let params = {
			// method: 'post',
			url: `system/user/avatar`,
			filePath: data,
			header: {
				'Authorization': 'Bearer ' + uni.getStorageSync('token'),
				'Content-Type': 'multipart/form-data'
			},
		}
		return uploadFile(params)
	},
	//获取验证图片
	reqGet(data) {
		let params = {
			url: `captcha/get`,
			method: 'post',
			headers: {
			  isToken: false
			},
			data
		}
		return request(params)
	},
	
	//滑动或者点选验证
	reqCheck(data) {
		let params = {
			url: `captcha/check`,
			method: 'post',
			headers: {
			  isToken: false
			},
			data
		}
		return request(params)
	},
}

export default user